import {reqToken} from '../../api/index';
Page({
     //授权回调
     goEdit(){
       //点击授权登录按钮:需要通过wx.login获取用户登录临时凭证code 
        wx.login({
          success: (res) => {
            //获取token
            this.getToken(res.code)
          },
        })
     },
     //获取用户token
     async getToken(code){
        const result =  await reqToken(code);
         if(result.code==200){
             //微信小程序本地持久化存储token 上限10M
             wx.setStorageSync('TOKEN', result.data.token);
             //跳转到编辑页
             wx.redirectTo({
               url: '/pages/edit/edit',
             })
         }
     }
})